﻿Calendars Page
<?php
	$date = time();
	
	$day = date('d', $date);
	$month = date('m', $date);
	$year = date('Y', $date);

	$first_day = mktime(0, 0, 0, $month, 1, $year);
		
	$title = date('F', $first_day);

	$day_of_week = date('D', $first_day);
	
	
	if($day_of_week == "Mon")
	{
		$blank = 0;
	}
	else if($day_of_week == "Tue")
	{
		$blank = 2;
	}
	else if($day_of_week == "Wed")
	{
		$blank = 3;
	}
	else if($day_of_week == "Thu")
	{
		$blank = 4;
	}
	else if($day_of_week == "Fri")
	{
		$blank = 5;
	}
	else if($day_of_week == "Sat")
	{
		$blank = 6;
	}
	else if($day_of_week == "Sun")
	{
		$blank = 6;
	}
	
	$days_in_month = cal_days_in_month(0, $month, $year);

	echo "<table border=1 width=294>";
	
	echo "<tr><th colspan=7> $title $year </th></tr>";
	
	echo "<tr>";
	
	echo "<td width=50 style='text-align:center'>Mon</td>";
	echo "<td width=50 style='text-align:center'>Tue</td>";
	echo "<td width=50 style='text-align:center'>Wen</td>";
	echo "<td width=50 style='text-align:center'>Thu</td>";
	echo "<td width=50 style='text-align:center'>Fri</td>";
	echo "<td width=50 style='text-align:center'>Sat</td>";
	echo "<td width=50 style='text-align:center'>Sun</td>";
	
	echo "</tr>";
	
	$day_count = 1;
	
	echo "<tr>";
	
	while( $blank > 1)
	{
		echo "<td></td>";
		$blank--;
		$day_count++;
	}
	
	$day_num = 1;
	
	while($day_num <= $days_in_month)
	{
		echo "<td style='text-align:center'> $day_num </td>";
		
		$day_num++;
	
		$day_count++;
		
		if($day_count>7)
		{
			echo "</tr><tr>";
			
			$day_count = 1;
		}
	}
	
	while($day_count > 1 && $day_count <= 7)
	{
		echo "<td></td>";
		
		$day_count++;		
	}
	
	echo "</tr></table>";
	
	echo "<br/><br/><br/><br/><br/>";
	
	$day = date('d', $date);
	$month = date('m', $date);
	$month++;
	
	$year = date('Y', $date);

	$first_day = mktime(0, 0, 0, $month, 1, $year);
		
	$title = date('F', $first_day);

	$day_of_week = date('D', $first_day);
	
	
	if($day_of_week == "Mon")
	{
		$blank = 0;
	}
	else if($day_of_week == "Tue")
	{
		$blank = 2;
	}
	else if($day_of_week == "Wed")
	{
		$blank = 3;
	}
	else if($day_of_week == "Thu")
	{
		$blank = 4;
	}
	else if($day_of_week == "Fri")
	{
		$blank = 5;
	}
	else if($day_of_week == "Sat")
	{
		$blank = 6;
	}
	else if($day_of_week == "Sun")
	{
		$blank = 6;
	}
	
	$days_in_month = cal_days_in_month(0, $month, $year);

	echo "<table border=1 width=294>";
	
	echo "<tr><th colspan=7> $title $year </th></tr>";
	
	echo "<tr>";
	
	echo "<td width=50 style='text-align:center'>Mon</td>";
	echo "<td width=50 style='text-align:center'>Tue</td>";
	echo "<td width=50 style='text-align:center'>Wen</td>";
	echo "<td width=50 style='text-align:center'>Thu</td>";
	echo "<td width=50 style='text-align:center'>Fri</td>";
	echo "<td width=50 style='text-align:center'>Sat</td>";
	echo "<td width=50 style='text-align:center'>Sun</td>";
	
	echo "</tr>";
	
	$day_count = 1;
	
	echo "<tr>";
	
	while( $blank > 1)
	{
		echo "<td></td>";
		$blank--;
		$day_count++;
	}
	
	$day_num = 1;
	
	while($day_num <= $days_in_month)
	{
		echo "<td style='text-align:center'> $day_num </td>";
		
		$day_num++;
	
		$day_count++;
		
		if($day_count>7)
		{
			echo "</tr><tr>";
			
			$day_count = 1;
		}
	}
	
	while($day_count > 1 && $day_count <= 7)
	{
		echo "<td></td>";
		
		$day_count++;		
	}
	
	echo "</tr></table>";
?>